/**
 * Licensee: DuKe TeAm
 * License Type: Purchased
 */
package ormsamples;

import org.orm.*;
public class DeleteCineData {
	public void deleteTestData() throws PersistentException {
		PersistentTransaction t = orm.CinePersistentManager.instance().getSession().beginTransaction();
		try {
			orm.DAOFactory lDAOFactory = orm.DAOFactory.getDAOFactory();
			orm.dao.PeliculaDAO lormPeliculaDAO = lDAOFactory.getPeliculaDAO();
			orm.Pelicula lormPelicula = lormPeliculaDAO.loadPeliculaByQuery(null, null);
			// Delete the persistent object
			lormPeliculaDAO.delete(lormPelicula);
			orm.dao.GeneroDAO lormGeneroDAO = lDAOFactory.getGeneroDAO();
			orm.Genero lormGenero = lormGeneroDAO.loadGeneroByQuery(null, null);
			// Delete the persistent object
			lormGeneroDAO.delete(lormGenero);
			orm.dao.ClasificacionDAO lormClasificacionDAO = lDAOFactory.getClasificacionDAO();
			orm.Clasificacion lormClasificacion = lormClasificacionDAO.loadClasificacionByQuery(null, null);
			// Delete the persistent object
			lormClasificacionDAO.delete(lormClasificacion);
			orm.dao.SalaDAO lormSalaDAO = lDAOFactory.getSalaDAO();
			orm.Sala lormSala = lormSalaDAO.loadSalaByQuery(null, null);
			// Delete the persistent object
			lormSalaDAO.delete(lormSala);
			t.commit();
		}
		catch (Exception e) {
			t.rollback();
		}
		
	}
	
	public static void main(String[] args) {
		try {
			DeleteCineData deleteCineData = new DeleteCineData();
			try {
				deleteCineData.deleteTestData();
			}
			finally {
				orm.CinePersistentManager.instance().disposePersistentManager();
			}
		}
		catch (Exception e) {
			e.printStackTrace();
		}
	}
}
